From e3ac3702839565cab50c5be45e313684dec5d9a6 Mon Sep 17 00:00:00 2001 From: tsteven4 Date: Sun, 9 Feb 2014 21:10:55 +0000 Subject: [PATCH] fix a few warnings and an inappropriate attempt to free memory. --- gpsbabel/pocketfms_wp.cc | 9 ++++----- gpsbabel/vecs.cc | 3 +-- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/gpsbabel/pocketfms_wp.cc b/gpsbabel/pocketfms_wp.cc index fc60a27f0..3e9246f5f 100644 --- a/gpsbabel/pocketfms_wp.cc +++ b/gpsbabel/pocketfms_wp.cc @@ -102,7 +102,6 @@ wr_init(const char* fname) static void enigma_waypt_disp(const Waypoint* wpt) { - char* t; #if NEW_STRINGS if (!wpt->shortname.isEmpty()) { // The output might have a space or control character. @@ -112,7 +111,7 @@ enigma_waypt_disp(const Waypoint* wpt) // The output might have a space or control character. int i, l = strlen(wpt->shortname); #endif - t = (char*) xmalloc(l + 1); + char *t = (char*) xmalloc(l + 1); char* d = t; for (i = 0; i < l; i++) { #if NEW_STRINGS @@ -125,11 +124,11 @@ enigma_waypt_disp(const Waypoint* wpt) } } *d = 0; + gbfprintf(file_out, "%s %f %f\n", t, wpt->latitude, wpt->longitude); + xfree(t); } else { - t = "NONAME"; + gbfprintf(file_out, "%s %f %f\n", "NONAME", wpt->latitude, wpt->longitude); } - gbfprintf(file_out, "%s %f %f\n", t, wpt->latitude, wpt->longitude); - xfree(t); } static void diff --git a/gpsbabel/vecs.cc b/gpsbabel/vecs.cc index ffa9421aa..7aed52844 100644 --- a/gpsbabel/vecs.cc +++ b/gpsbabel/vecs.cc @@ -1371,7 +1371,7 @@ GET_OPTION(const char* iarglist, const char* argname, DEBUG_PARAMS) get_option(const char* iarglist, const char* argname) #endif { - size_t arglen = strlen(argname); + const size_t arglen = strlen(argname); char* arglist; char* rval = NULL; char* arg; @@ -1381,7 +1381,6 @@ get_option(const char* iarglist, const char* argname) return NULL; } - arglen = strlen(argname); arglist = xstrdup(iarglist); for (arg = arglist; argp = strtok(arg, ","), NULL != argp; arg = NULL) { -- 2.30.2